angular.module('app.baseinfo')

    .factory('userService', ["$http", "config", function ($http, config) {

        var baseUrl = config.baseUrl;

        var ret = {};

        ret.addUser = function (user) {
            var url = baseUrl + "/users";
            return $http.post(url, user);
        };

        ret.getUsers = function (query) {
            var url = baseUrl + "/users";
            return $http.get(url, {params: query});
        };

        ret.getUser = function (user) {
            var url = baseUrl + "/users/" + user.userId;
            return $http.get(url);
        };

        ret.removeRecord = function (e) {
            var url = baseUrl + "/users/" + e.id;
            return $http.delete(url);
        };

        ret.updateUser = function (user) {
            var url = baseUrl + "/users/" + user.userId;
            return $http.put(url, user);
        };


        ret.changeUserPassword = function (user) {
            var url = baseUrl + "/users/password";
            return $http.post(url, user);
        };
        ret.changePassword = function (user) {
            var url = baseUrl + "/password";
            return $http.post(url, user);
        };

        //积分记录
        ret.scoreRecordsList = function (query) {
            var url = baseUrl + "/scoreRecords";
            return $http.get(url, {params: query});
        };

        ret.addRecord = function (recordDetail) {
            var url = baseUrl + "/scoreRecords";
            return $http.post(url, recordDetail);
        };



        return ret;
    }]);